#include "../pre_emptive_os/api/osapi.h"
#include "../pre_emptive_os/api/general.h"
#include <printf_P.h>
#include <lpc2xxx.h>
#include <consol.h>

#define LCD_DATA      0x00ff0000  //P1.16-P1.23
#define LCD_E         0x02000000  //P1.25
#define LCD_RW        0x00400000  //P0.22
#define LCD_RS        0x01000000  //P1.24
#define LCD_BACKLIGHT 0x40000000  //P0.30

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Use lcdInit()
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void initLCD(void);

void delay37us(void);

void writeLCD(tU8 reg, tU8 data);

void lcdBacklight(tU8 onOff);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Writes N letters of giver char table. Unsefe memorywise.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void writeString(char * s, int N);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Sets cursor at the beginning of the first line
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void resetCursor();

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Writes N letters of giver char table. Unsefe memorywise.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void writeString(char * s, int N);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Initializes the LCD. Use this instead of initLCD
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void lcdInit(void);


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Displays Celcius sign...
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void printCelsius();

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Prints as many spaces as given in parameter
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void printPadding(int N);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Real display function. See printInt
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int print(int * figure);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Displays integer value on the LCD screen and returns
 * number of characters (including '-' sign)
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int printInt(int figure);
